package com.google.code.japndroid;

import android.content.Context;
import android.net.wifi.WifiManager;
import android.bluetooth.BluetoothAdapter;

public final class PacketKillerUtils {
	/*
    public static void broadcastStatusChange(Context context, boolean isEnabled) {
        Intent message = new Intent(PacketKillerConstants.STATUS_CHANGED_ON_CLICK);
        message.putExtra(Constants.STATUS_EXTRA, isEnabled);
        context.sendBroadcast(message);
    }
*/
	public static boolean isWifiConnectedOrConnecting(
			Context context) {
		WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
		
		return wifiManager.isWifiEnabled();
	}

	public static void setEnableWifi(Context context,boolean enable) {
		WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

		// android.permission.CHANGE_WIFI_STATE
		wifiManager.setWifiEnabled(enable); // true or false
	}

	public static boolean canBlueToothAvailable(){
		return (BluetoothAdapter.getDefaultAdapter() != null );
	}
	public static boolean isBlueToothActive() {
		BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
		boolean flg = false;
		if (mBluetoothAdapter != null) {
			flg = mBluetoothAdapter.isEnabled();
		}
		return flg;
	}

	public static void setEnableBlueTooth(boolean enable) {
		// TODO Auto-generated method stub
		BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
		if( mBluetoothAdapter != null ){
			if( enable ){
				mBluetoothAdapter.enable();
			}else{
				mBluetoothAdapter.disable();
			}
		}
	}
}
